home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.04 Apr 90 / List Demo Project / KeyBoard.p < prev    next >
Encoding:
Text File  |  1989-08-02  |  2.0 KB  |  83 lines  |  [TEXT/PJMM]

  1. unit KeyBoard;
  2. interface
  3.     const
  4.         LeftCursor = $46;
  5.         RightCursor = $42;
  6.         UpCursor = $4D;
  7.         DownCursor = $48;
  8. {now for the Mac SE and II keyboards}
  9.         xLeftCursor = $7B;
  10.         xRightCursor = $7C;
  11.         xDownCursor = $7D;
  12.         xUpCursor = $7E;
  13.  
  14.         ReturnKey = $24;
  15.         EnterKey = $4C;
  16.         TabKey = $30;
  17.         HelpKey = $72;
  18.  
  19.         xKey = 7;
  20.         cKey = 8;
  21.         vKey = 9;
  22.         dummyClearKey = $FFFF;
  23.         dummyOptionPasteKey = $FFFE;
  24.     type
  25.         CursorType = (noCurs, LeftCurs, RightCurs, UpCurs, DownCurs, TabCurs, Carriage);
  26.  
  27.     function whichCursor (keyCode: byte): CursorType;
  28. {The following were gratefully taken from Warren P. Michelsen}
  29. {MacTutor, May 1988, page 9}
  30.     function SpaceKeyDown: boolean;
  31.     function PeriodKeyDown: boolean;
  32.     function CommandKeyDown: boolean;
  33.     function OptionKeyDown: boolean;
  34. implementation
  35. {**************************************************}
  36.     function TestKey (i: longint): boolean;
  37.         var
  38.             myKeys: keyMap;
  39.     begin
  40.         GetKeys(myKeys);
  41.         TestKey := BitTst(@myKeys[1], i)
  42.     end;
  43. {**************************************************}
  44.     function SpaceKeyDown: boolean;
  45.     begin
  46.         SpaceKeyDown := TestKey(22);
  47.     end;
  48. {**************************************************}
  49.     function whichCursor (keyCode: byte): CursorType;
  50.     begin
  51.         case KeyCode of
  52.             LeftCursor, xLeftCursor: 
  53.                 whichCursor := leftCurs;
  54.             RightCursor, xRightCursor: 
  55.                 whichCursor := RightCurs;
  56.             DownCursor, xDownCursor: 
  57.                 whichCursor := DownCurs;
  58.             UpCursor, xUpCursor: 
  59.                 whichCursor := UpCurs;
  60.             TabKey: 
  61.                 whichCursor := TabCurs;
  62.             ReturnKey: 
  63.                 whichCursor := Carriage;
  64.             otherwise
  65.                 whichCursor := noCurs;
  66.         end;{case}
  67.     end;
  68. {**************************************************}
  69.     function PeriodKeyDown: boolean;
  70.     begin
  71.         PeriodKeyDown := TestKey(8);
  72.     end;
  73. {**************************************************}
  74.     function OptionKeyDown: boolean;
  75.     begin
  76.         OptionKeyDown := TestKey(29);
  77.     end;
  78. {**************************************************}
  79.     function CommandKeyDown: boolean;
  80.     begin
  81.         CommandKeyDown := TestKey(16);
  82.     end;
  83. end.